<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<script type="text/javascript">
		function Fn(){
			var _this = this;
			this.a = 5;

			/*//错误。this指向是按钮
			document.getElementById('btn').onclick = this.show;*/

			//改正
			document.getElementById('btn').onclick = function (){
				_this.show();			//带括号
			}
		}

		Fn.prototype.show = function (){
			alert(this.a)
		}

		window.onload = function (){
			new Fn();		//这个必须要放在window.onload里面
		}
		
	</script>
</head>
<body>
	<input id="btn" type="button" value="按钮" />
</body>
</html>